package com.cqc.manage.repositories;

import com.cqc.manage.entity.MessageBusiness;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface MessageBusinessRepositories extends JpaRepository<MessageBusiness,String> ,JpaSpecificationExecutor<MessageBusiness>{

    /**
     * 查询工程师未收款业务  条件查询
     * @param specification
     * @return
     */
    List<MessageBusiness> findAll(Specification<MessageBusiness> specification);

    void deleteByEngineer(String engineer);

    /**
     * 查询所有业务
     * @param specification
     * @return
     */
    Page<MessageBusiness> findAll(Specification<MessageBusiness> specification,Pageable pageable);

    /**
     * 通过用合同编号查询合同信息
     * @param contractNo
     * @return
     */
    MessageBusiness findByContractNo(String contractNo);


    @Query(nativeQuery = true ,value = "select contract_no from message_business where engineer = ?")
    List<String> getAllContractNo(String engineer);

    MessageBusiness findByContractNoAndEngineer(String contractNo,String engName);



}
